Update key vault data sdk to T2, mangement SDK to latest.#3
Conversation
…" to the value read from app.config. AzureEnvironment.AzureGlobalCloud remains as default.
| /// <summary> | ||
| /// Generic ADAL Authentication callback | ||
| /// </summary> | ||
| public static async Task<string> AcquireTokenAsync(string authority, string resource, string scope) |
There was a problem hiding this comment.
To track 2, there is new SecretClient instead of KeyVaultClient to use. this AcquireTokenAsync() is used to create KeyVaultClient in KeyvaultSampleBase delegate. So this is decided to remove
| // instantiate the data client | ||
| DataClient = new KeyVaultClient(ClientContext.AcquireTokenAsync); | ||
| //Get current Authority Host for Azure | ||
| TokenCredentialOptions options = new TokenCredentialOptions(); |
There was a problem hiding this comment.
if we did not set options.AuthorityHost, ClientSecretCredential will always set as default "AzureGlobalCloud"
|
Please try with the new preview mgmt libs: https://www.nuget.org/packages/Azure.ResourceManager.KeyVault/1.0.0-preview.1 |
|
Service: KeyVault; SDK: key vault mgmt sdk and azure key vault data sdk(t1)
|
|
@heaths - Can you please review? |
heaths
left a comment
There was a problem hiding this comment.
Needs a few changes, but otherwise LGTM.
| @@ -13,8 +10,6 @@ namespace AzureKeyVaultRecoverySamples | |||
| /// </summary> | |||
| public sealed class ClientContext | |||
There was a problem hiding this comment.
None of this class is really used anymore. Perhaps just replace it with the DefaultAzureCredential directly in the client like we normally do in samples. I worry the unnecessary complexity here will just make people copy the design when simply passing a DefaultAzureCredential is so much simpler.
|
|
||
| // wait for purge complete | ||
| Console.Write("Waiting for Purging complete..."); | ||
| Thread.Sleep(60 * 1000); |
There was a problem hiding this comment.
While sleeping for a bit is a good idea (and there's nothing more we can do anyway), you should actually have a limited retry loop. Purging can take a while, and will vary (it may be a scheduled task in the backend).
There was a problem hiding this comment.
@heaths , i am not sure how to implement this limited retry loop. As i think there's nothing more we can do here.
|
|
||
| Console.Write("Retrieving newly created vault..."); | ||
| var retrievedVault = await sample.ManagementClient.Vaults.GetAsync(rgName, vaultName).ConfigureAwait(false); | ||
| var retrievedVault = (await sample.ManagementClient.Vaults.GetAsync(rgName, vaultName).ConfigureAwait(false)).Value; |
There was a problem hiding this comment.
Like the sample above, I'd stick with Response<T> here and use its Value property only when needed.
| /// </summary> | ||
| protected ClientContext context; | ||
|
|
||
There was a problem hiding this comment.
Nit: git doesn't like whitespace-only lines.
| - dotnet-core | ||
| description: "This repo contains sample code demonstrating the backup/restore and recoverable deletion functionality of Azure Key Vault using the Azure .NET SDK." | ||
| urlFragment: net-sdk-samples | ||
| urlFragment: key-vault-dotnet-recovery |
There was a problem hiding this comment.
This will result in broken links. urlFragment should neve be changed. It's unfortunate it was generic before, but should remain the same. Just be more specific going forward.
| To complete this tutorial: | ||
|
|
||
| The recoverable deletion functionality is also referred to as 'soft delete'; consequently, a permanent, irrecoverable deletion is referred to as 'purge'. | ||
| * Install .NET Core 2.0 version for [Linux] or [Windows] |
There was a problem hiding this comment.
2.0 is out of support. 2.1 is LTS, but so is 3.1. We should at least recommend an LTS.
| ### Create an App registration using the Azure Portal | ||
|
|
||
| ## Getting Started | ||
| * Go to the [Azure Portal] and log in using your Azure account. |
There was a problem hiding this comment.
Steps should be numbered. Alternatives should be bulleted.
| [free account]: https://azure.microsoft.com/free/?WT.mc_id=A261C142F | ||
| [Azure Portal]: https://portal.azure.com | ||
| [Recovery scenario samples for Azure Key Vault using the Azure Node SDK]: https://docs.microsoft.com/en-us/samples/azure-samples/key-vault-node-recovery/key-vault-node-recovery/ | ||
| [Azure Key Vault documentation]: https://docs.microsoft.com/en-us/azure/key-vault/general/basic-concepts |
There was a problem hiding this comment.
URLs should not include the locale. In VSCode, install the Microsoft Docs Authoring Pack for rules you should follow when writing markdowns (it would catch this issue).
I see a couple URLs like that. This always goes to the specified language/locale, while leaving it out uses the browsers' preferred languages (better for non-en-US readers).
|
Happy to review, but @jongio or @wantedfast, could I get a review on my sample at Azure/azure-sdk-for-net#15123? It's been sitting there for quite a while. The brunt of it was previously reviewed by Alex at its original home (https://github.com/heaths/KeyVaultProxy), but I had to make a few changes to build / run in our repo, per @weshaggard's desire to host samples in a single place going forward. |
|
@wantedfast @heaths just FYI - .NET SDK team is designing a new set of APIs that will be previewed at the end of year. There can be some upcoming changes in this key vault code sample. The Track 2 .NET SDK won't be GA-ed for a while, so if we expect the customer to see a stable version in a code sample, probably better to stay on Track 1, otherwise, feel free to update to Track 2. |
|
The preview functionality coming out later is in addition to what is here. We're aren't changing anything that is demo'd here. Seems better to show customers more track 2 code since we are deprecating track 1. |
e21e18a to
f406984
Compare
|
If possible, please avoid force-pushing until you're ready to merge (for example, if rebasing on master to pick up recent changes). I can't tell what's changed so I will have to re-review the entire PR again. |
| catch (CloudException ce) | ||
| { | ||
| Console.WriteLine("Unexpected ARM exception encountered: {0}", ce.Message); | ||
| Console.WriteLine("Unexpected KeyVault exception encountered: {0}", ex.Message); |
There was a problem hiding this comment.
Nit: the product name is "Key Vault" (with a space). We should use that in customer-facing messages / docs.
| /// </summary> | ||
| protected ClientContext context; | ||
|
|
||
| To complete this tutorial: | ||
|
|
||
| The recoverable deletion functionality is also referred to as 'soft delete'; consequently, a permanent, irrecoverable deletion is referred to as 'purge'. | ||
| * Install .NET Core 3.1 version for [Linux] or [Windows] |
There was a problem hiding this comment.
Use - consistently throughout the markdown (you use mainly this below).
There was a problem hiding this comment.
U mentioned steps need numbered, alternative should be bulleted. I think this is much better than mix them.
Do you still think we should keep consistency or changing below with numbered steps?
Like what i have done now.
|
Sorry for let you review again, this force-pushing is because this PR needs step back. I will be more careful with force-pushing next time. |
Purpose
Update key vault data sdk to T2, key vault management SDK to latest.